package org.tigris.subversion.svnant.commands;

import org.apache.tools.ant.Project;
import org.tigris.subversion.svnant.SvnAntUtilities;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.ISVNDirEntry;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNNodeKind;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class List extends SvnCommand
{
  private static final String MSG_CANT_LIST = "Can't list";
  private SVNUrl url = null;
  private boolean recurse = false;
  private SVNRevision revision = SVNRevision.HEAD;
  private boolean onlynames = false;
  private String delimiter = ",";
  private boolean listFiles = true;
  private boolean listDirs = true;
  private String property;

  public void execute()
  {
    try
    {
      ISVNDirEntry[] arrayOfISVNDirEntry = getClient().getList(this.url, this.revision, this.recurse);
      int i = 0;
      for (int j = 0; j < arrayOfISVNDirEntry.length; j++)
        if (arrayOfISVNDirEntry[j].getNodeKind() == SVNNodeKind.DIR)
        {
          if (this.listDirs)
            continue;
          arrayOfISVNDirEntry[j] = null;
          i++;
        }
        else if (arrayOfISVNDirEntry[j].getNodeKind() == SVNNodeKind.FILE)
        {
          if (this.listFiles)
            continue;
          arrayOfISVNDirEntry[j] = null;
          i++;
        }
        else
        {
          arrayOfISVNDirEntry[j] = null;
          i++;
        }
      StringBuffer localStringBuffer = new StringBuffer();
      if (i < arrayOfISVNDirEntry.length)
      {
        int k = 0;
        for (int m = 0; m < arrayOfISVNDirEntry.length; m++)
        {
          if (arrayOfISVNDirEntry[m] == null)
            continue;
          if (k > 0)
            localStringBuffer.append(this.delimiter);
          String str = arrayOfISVNDirEntry[m].getPath();
          if (!this.onlynames)
            str = this.url.appendPath(str).toString();
          localStringBuffer.append(str);
          k++;
        }
      }
      getProject().setProperty(this.property, localStringBuffer.toString());
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Can't list", new Object[0]);
    }
  }

  protected void validateAttributes()
  {
    SvnAntUtilities.attrNotNull("url", this.url);
    SvnAntUtilities.attrNotNull("revision", this.revision);
    SvnAntUtilities.attrNotEmpty("delimiter", this.delimiter);
    SvnAntUtilities.attrNotEmpty("property", this.property);
  }

  public void setListFiles(boolean paramBoolean)
  {
    this.listFiles = paramBoolean;
  }

  public void setListDirs(boolean paramBoolean)
  {
    this.listDirs = paramBoolean;
  }

  public void setOnlyNames(boolean paramBoolean)
  {
    this.onlynames = paramBoolean;
  }

  public void setDelimiter(String paramString)
  {
    this.delimiter = paramString;
  }

  public void setUrl(SVNUrl paramSVNUrl)
  {
    this.url = paramSVNUrl;
  }

  public void setRevision(String paramString)
  {
    this.revision = getRevisionFrom(paramString);
  }

  public void setProperty(String paramString)
  {
    this.property = paramString;
  }

  public void setRecurse(boolean paramBoolean)
  {
    this.recurse = paramBoolean;
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.List
 * JD-Core Version:    0.6.0
 */